package com.gt.service.security;

import com.gt.dao.security.UserMapperDAO;
import com.gt.entity.security.LoginDetail;
import com.gt.entity.security.TokenDetail;
import com.gt.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {

    private final UserMapperDAO userMapper;
    private final TokenUtils tokenUtils;

    @Autowired
    public LoginServiceImpl(UserMapperDAO userMapper, TokenUtils tokenUtils) {
        this.userMapper = userMapper;
        this.tokenUtils = tokenUtils;
    }


    @Override
    public LoginDetail getLoginDetail(String username) {
        return this.userMapper.getUserByName(username);
    }

    @Override
    public String generateToken(TokenDetail tokenDetail) {
        return tokenUtils.generateToken(tokenDetail);
    }

}
